
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" lang="zh_CN">
  <head>
    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>wave --- 读写WAV格式文件 &#8212; Python 3.7.3 文档</title>
    <link rel="stylesheet" href="../_static/pydoctheme.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    
    <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/underscore.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <script type="text/javascript" src="../_static/language_data.js"></script>
    <script type="text/javascript" src="../_static/translations.js"></script>
    
    <script type="text/javascript" src="../_static/sidebar.js"></script>
    
    <link rel="search" type="application/opensearchdescription+xml"
          title="在 Python 3.7.3 文档 中搜索"
          href="../_static/opensearch.xml"/>
    <link rel="author" title="关于这些文档" href="../about.html" />
    <link rel="index" title="索引" href="../genindex.html" />
    <link rel="search" title="搜索" href="../search.html" />
    <link rel="copyright" title="版权所有" href="../copyright.html" />
    <link rel="next" title="chunk --- Read IFF chunked data" href="chunk.html" />
    <link rel="prev" title="sunau --- 读写 Sun AU 文件" href="sunau.html" />
    <link rel="shortcut icon" type="image/png" href="../_static/py.png" />
    <link rel="canonical" href="https://docs.python.org/3/library/wave.html" />
    
    <script type="text/javascript" src="../_static/copybutton.js"></script>
    <script type="text/javascript" src="../_static/switchers.js"></script>
    
    
    
    <style>
      @media only screen {
        table.full-width-table {
            width: 100%;
        }
      }
    </style>
 

  </head><body>  
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>导航</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="总目录"
             accesskey="I">索引</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python 模块索引"
             >模块</a> |</li>
        <li class="right" >
          <a href="chunk.html" title="chunk --- Read IFF chunked data"
             accesskey="N">下一页</a> |</li>
        <li class="right" >
          <a href="sunau.html" title="sunau --- 读写 Sun AU 文件"
             accesskey="P">上一页</a> |</li>
        <li><img src="../_static/py.png" alt=""
                 style="vertical-align: middle; margin-top: -1px"/></li>
        <li><a href="https://www.python.org/">Python</a> &#187;</li>
        <li>
          <span class="language_switcher_placeholder">zh_CN</span>
          <span class="version_switcher_placeholder">3.7.3</span>
          <a href="../index.html">文档</a> &#187;
        </li>

          <li class="nav-item nav-item-1"><a href="index.html" >Python 标准库</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="mm.html" accesskey="U">多媒体服务</a> &#187;</li>
    <li class="right">
        

    <div class="inline-search" style="display: none" role="search">
        <form class="inline-search" action="../search.html" method="get">
          <input placeholder="快速搜索" type="text" name="q" />
          <input type="submit" value="转向" />
          <input type="hidden" name="check_keywords" value="yes" />
          <input type="hidden" name="area" value="default" />
        </form>
    </div>
    <script type="text/javascript">$('.inline-search').show(0);</script>
         |
    </li>

      </ul>
    </div>    

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <div class="section" id="module-wave">
<span id="wave-read-and-write-wav-files"></span><h1><a class="reference internal" href="#module-wave" title="wave: Provide an interface to the WAV sound format."><code class="xref py py-mod docutils literal notranslate"><span class="pre">wave</span></code></a> --- 读写WAV格式文件<a class="headerlink" href="#module-wave" title="永久链接至标题">¶</a></h1>
<p><strong>源代码:</strong> <a class="reference external" href="https://github.com/python/cpython/tree/3.7/Lib/wave.py">Lib/wave.py</a></p>
<hr class="docutils" />
<p><a class="reference internal" href="#module-wave" title="wave: Provide an interface to the WAV sound format."><code class="xref py py-mod docutils literal notranslate"><span class="pre">wave</span></code></a> 模块提供了一个处理 WAV 声音格式的便利接口。它不支持压缩/解压，但是支持单声道/立体声。</p>
<p><a class="reference internal" href="#module-wave" title="wave: Provide an interface to the WAV sound format."><code class="xref py py-mod docutils literal notranslate"><span class="pre">wave</span></code></a> 模块定义了以下函数和异常:</p>
<dl class="function">
<dt id="wave.open">
<code class="descclassname">wave.</code><code class="descname">open</code><span class="sig-paren">(</span><em>file</em>, <em>mode=None</em><span class="sig-paren">)</span><a class="headerlink" href="#wave.open" title="永久链接至目标">¶</a></dt>
<dd><p>如果 <em>file</em> 是一个字符串，打开对应文件名的文件。否则就把它作为文件类对象来处理。<em>mode</em> 可以为以下值：</p>
<dl class="docutils">
<dt><code class="docutils literal notranslate"><span class="pre">'rb'</span></code></dt>
<dd>只读模式。</dd>
<dt><code class="docutils literal notranslate"><span class="pre">'wb'</span></code></dt>
<dd>只写模式。</dd>
</dl>
<p>注意不支持同时读写WAV文件。</p>
<p><em>mode</em> 设为 <code class="docutils literal notranslate"><span class="pre">'rb'</span></code> 时返回一个 <code class="xref py py-class docutils literal notranslate"><span class="pre">Wave_read</span></code> 对象，而 <em>mode</em> 设为 <code class="docutils literal notranslate"><span class="pre">'wb'</span></code> 时返回一个 <code class="xref py py-class docutils literal notranslate"><span class="pre">Wave_write</span></code> 对象。如果省略 <em>mode</em> 并指定 <em>file</em> 来传入一个文件类对象，则 <code class="docutils literal notranslate"><span class="pre">file.mode</span></code> 会被用作 <em>mode</em> 的默认值。</p>
<p>如果操作的是文件对象，当使用 wave 对象的 <code class="xref py py-meth docutils literal notranslate"><span class="pre">close()</span></code> 方法时，并不会真正关闭文件对象，这需要调用者负责来关闭文件对象。</p>
<p>The <a class="reference internal" href="#wave.open" title="wave.open"><code class="xref py py-func docutils literal notranslate"><span class="pre">open()</span></code></a> function may be used in a <a class="reference internal" href="../reference/compound_stmts.html#with"><code class="xref std std-keyword docutils literal notranslate"><span class="pre">with</span></code></a> statement.  When
the <code class="xref std std-keyword docutils literal notranslate"><span class="pre">with</span></code> block completes, the <a class="reference internal" href="#wave.Wave_read.close" title="wave.Wave_read.close"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Wave_read.close()</span></code></a> or <a class="reference internal" href="#wave.Wave_write.close" title="wave.Wave_write.close"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Wave_write.close()</span></code></a> method is called.</p>
<div class="versionchanged">
<p><span class="versionmodified">在 3.4 版更改: </span>添加了对不可搜索文件的支持。</p>
</div>
</dd></dl>

<dl class="function">
<dt id="wave.openfp">
<code class="descclassname">wave.</code><code class="descname">openfp</code><span class="sig-paren">(</span><em>file</em>, <em>mode</em><span class="sig-paren">)</span><a class="headerlink" href="#wave.openfp" title="永久链接至目标">¶</a></dt>
<dd><p>同 <a class="reference internal" href="#wave.open" title="wave.open"><code class="xref py py-func docutils literal notranslate"><span class="pre">open()</span></code></a>，用于向后兼容。</p>
<div class="deprecated">
<p><span class="versionmodified">Deprecated since version 3.7, will be removed in version 3.9.</span></p>
</div>
</dd></dl>

<dl class="exception">
<dt id="wave.Error">
<em class="property">exception </em><code class="descclassname">wave.</code><code class="descname">Error</code><a class="headerlink" href="#wave.Error" title="永久链接至目标">¶</a></dt>
<dd><p>当不符合WAV格式或无法操作时引发的错误。</p>
</dd></dl>

<div class="section" id="wave-read-objects">
<span id="id1"></span><h2>Wave_read对象<a class="headerlink" href="#wave-read-objects" title="永久链接至标题">¶</a></h2>
<p>由 <a class="reference internal" href="#wave.open" title="wave.open"><code class="xref py py-func docutils literal notranslate"><span class="pre">open()</span></code></a> 返回的 Wave_read 对象，有以下几种方法:</p>
<dl class="method">
<dt id="wave.Wave_read.close">
<code class="descclassname">Wave_read.</code><code class="descname">close</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#wave.Wave_read.close" title="永久链接至目标">¶</a></dt>
<dd><p>关闭 <a class="reference internal" href="#module-wave" title="wave: Provide an interface to the WAV sound format."><code class="xref py py-mod docutils literal notranslate"><span class="pre">wave</span></code></a> 打开的数据流并使对象不可用。当对象销毁时会自动调用。</p>
</dd></dl>

<dl class="method">
<dt id="wave.Wave_read.getnchannels">
<code class="descclassname">Wave_read.</code><code class="descname">getnchannels</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#wave.Wave_read.getnchannels" title="永久链接至目标">¶</a></dt>
<dd><p>返回声道数量（<code class="docutils literal notranslate"><span class="pre">1</span></code> 为单声道，<code class="docutils literal notranslate"><span class="pre">2</span></code> 为立体声）</p>
</dd></dl>

<dl class="method">
<dt id="wave.Wave_read.getsampwidth">
<code class="descclassname">Wave_read.</code><code class="descname">getsampwidth</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#wave.Wave_read.getsampwidth" title="永久链接至目标">¶</a></dt>
<dd><p>返回采样字节长度。</p>
</dd></dl>

<dl class="method">
<dt id="wave.Wave_read.getframerate">
<code class="descclassname">Wave_read.</code><code class="descname">getframerate</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#wave.Wave_read.getframerate" title="永久链接至目标">¶</a></dt>
<dd><p>返回采样频率。</p>
</dd></dl>

<dl class="method">
<dt id="wave.Wave_read.getnframes">
<code class="descclassname">Wave_read.</code><code class="descname">getnframes</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#wave.Wave_read.getnframes" title="永久链接至目标">¶</a></dt>
<dd><p>返回音频总帧数。</p>
</dd></dl>

<dl class="method">
<dt id="wave.Wave_read.getcomptype">
<code class="descclassname">Wave_read.</code><code class="descname">getcomptype</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#wave.Wave_read.getcomptype" title="永久链接至目标">¶</a></dt>
<dd><p>返回压缩类型（只支持 <code class="docutils literal notranslate"><span class="pre">'NONE'</span></code> 类型）</p>
</dd></dl>

<dl class="method">
<dt id="wave.Wave_read.getcompname">
<code class="descclassname">Wave_read.</code><code class="descname">getcompname</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#wave.Wave_read.getcompname" title="永久链接至目标">¶</a></dt>
<dd><p><a class="reference internal" href="#wave.Wave_read.getcomptype" title="wave.Wave_read.getcomptype"><code class="xref py py-meth docutils literal notranslate"><span class="pre">getcomptype()</span></code></a> 的通俗版本。使用 <code class="docutils literal notranslate"><span class="pre">'not</span> <span class="pre">compressed'</span></code> 代替 <code class="docutils literal notranslate"><span class="pre">'NONE'</span></code>。</p>
</dd></dl>

<dl class="method">
<dt id="wave.Wave_read.getparams">
<code class="descclassname">Wave_read.</code><code class="descname">getparams</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#wave.Wave_read.getparams" title="永久链接至目标">¶</a></dt>
<dd><p>返回一个 <a class="reference internal" href="collections.html#collections.namedtuple" title="collections.namedtuple"><code class="xref py py-func docutils literal notranslate"><span class="pre">namedtuple()</span></code></a> <code class="docutils literal notranslate"><span class="pre">(nchannels,</span> <span class="pre">sampwidth,</span> <span class="pre">framerate,</span> <span class="pre">nframes,</span> <span class="pre">comptype,</span> <span class="pre">compname)</span></code>，与 <code class="xref py py-meth docutils literal notranslate"><span class="pre">get*()</span></code> 方法的输出相同。</p>
</dd></dl>

<dl class="method">
<dt id="wave.Wave_read.readframes">
<code class="descclassname">Wave_read.</code><code class="descname">readframes</code><span class="sig-paren">(</span><em>n</em><span class="sig-paren">)</span><a class="headerlink" href="#wave.Wave_read.readframes" title="永久链接至目标">¶</a></dt>
<dd><p>读取并返回以 <a class="reference internal" href="stdtypes.html#bytes" title="bytes"><code class="xref py py-class docutils literal notranslate"><span class="pre">bytes</span></code></a> 对象表示的最多 <em>n</em> 帧音频。</p>
</dd></dl>

<dl class="method">
<dt id="wave.Wave_read.rewind">
<code class="descclassname">Wave_read.</code><code class="descname">rewind</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#wave.Wave_read.rewind" title="永久链接至目标">¶</a></dt>
<dd><p>设置当前文件指针位置。</p>
</dd></dl>

<p>后面两个方法是为了和 <a class="reference internal" href="aifc.html#module-aifc" title="aifc: Read and write audio files in AIFF or AIFC format."><code class="xref py py-mod docutils literal notranslate"><span class="pre">aifc</span></code></a> 保持兼容，实际不做任何事情。</p>
<dl class="method">
<dt id="wave.Wave_read.getmarkers">
<code class="descclassname">Wave_read.</code><code class="descname">getmarkers</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#wave.Wave_read.getmarkers" title="永久链接至目标">¶</a></dt>
<dd><p>返回 <code class="docutils literal notranslate"><span class="pre">None</span></code>。</p>
</dd></dl>

<dl class="method">
<dt id="wave.Wave_read.getmark">
<code class="descclassname">Wave_read.</code><code class="descname">getmark</code><span class="sig-paren">(</span><em>id</em><span class="sig-paren">)</span><a class="headerlink" href="#wave.Wave_read.getmark" title="永久链接至目标">¶</a></dt>
<dd><p>引发错误异常。</p>
</dd></dl>

<p>以下两个方法都使用指针，具体实现由其底层决定。</p>
<dl class="method">
<dt id="wave.Wave_read.setpos">
<code class="descclassname">Wave_read.</code><code class="descname">setpos</code><span class="sig-paren">(</span><em>pos</em><span class="sig-paren">)</span><a class="headerlink" href="#wave.Wave_read.setpos" title="永久链接至目标">¶</a></dt>
<dd><p>设置文件指针到指定位置。</p>
</dd></dl>

<dl class="method">
<dt id="wave.Wave_read.tell">
<code class="descclassname">Wave_read.</code><code class="descname">tell</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#wave.Wave_read.tell" title="永久链接至目标">¶</a></dt>
<dd><p>返回当前文件指针位置。</p>
</dd></dl>

</div>
<div class="section" id="wave-write-objects">
<span id="id2"></span><h2>Wave_write 对象<a class="headerlink" href="#wave-write-objects" title="永久链接至标题">¶</a></h2>
<p>For seekable output streams, the <code class="docutils literal notranslate"><span class="pre">wave</span></code> header will automatically be updated
to reflect the number of frames actually written.  For unseekable streams, the
<em>nframes</em> value must be accurate when the first frame data is written.  An
accurate <em>nframes</em> value can be achieved either by calling
<a class="reference internal" href="#wave.Wave_write.setnframes" title="wave.Wave_write.setnframes"><code class="xref py py-meth docutils literal notranslate"><span class="pre">setnframes()</span></code></a> or <a class="reference internal" href="#wave.Wave_write.setparams" title="wave.Wave_write.setparams"><code class="xref py py-meth docutils literal notranslate"><span class="pre">setparams()</span></code></a> with the number
of frames that will be written before <a class="reference internal" href="#wave.Wave_write.close" title="wave.Wave_write.close"><code class="xref py py-meth docutils literal notranslate"><span class="pre">close()</span></code></a> is called and
then using <a class="reference internal" href="#wave.Wave_write.writeframesraw" title="wave.Wave_write.writeframesraw"><code class="xref py py-meth docutils literal notranslate"><span class="pre">writeframesraw()</span></code></a> to write the frame data, or by
calling <a class="reference internal" href="#wave.Wave_write.writeframes" title="wave.Wave_write.writeframes"><code class="xref py py-meth docutils literal notranslate"><span class="pre">writeframes()</span></code></a> with all of the frame data to be
written.  In the latter case <a class="reference internal" href="#wave.Wave_write.writeframes" title="wave.Wave_write.writeframes"><code class="xref py py-meth docutils literal notranslate"><span class="pre">writeframes()</span></code></a> will calculate
the number of frames in the data and set <em>nframes</em> accordingly before writing
the frame data.</p>
<p>由 <a class="reference internal" href="#wave.open" title="wave.open"><code class="xref py py-func docutils literal notranslate"><span class="pre">open()</span></code></a> 返回的 Wave_write 对象，有以下几种方法:</p>
<div class="versionchanged">
<p><span class="versionmodified">在 3.4 版更改: </span>添加了对不可搜索文件的支持。</p>
</div>
<dl class="method">
<dt id="wave.Wave_write.close">
<code class="descclassname">Wave_write.</code><code class="descname">close</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#wave.Wave_write.close" title="永久链接至目标">¶</a></dt>
<dd><p>Make sure <em>nframes</em> is correct, and close the file if it was opened by
<a class="reference internal" href="#module-wave" title="wave: Provide an interface to the WAV sound format."><code class="xref py py-mod docutils literal notranslate"><span class="pre">wave</span></code></a>.  This method is called upon object collection.  It will raise
an exception if the output stream is not seekable and <em>nframes</em> does not
match the number of frames actually written.</p>
</dd></dl>

<dl class="method">
<dt id="wave.Wave_write.setnchannels">
<code class="descclassname">Wave_write.</code><code class="descname">setnchannels</code><span class="sig-paren">(</span><em>n</em><span class="sig-paren">)</span><a class="headerlink" href="#wave.Wave_write.setnchannels" title="永久链接至目标">¶</a></dt>
<dd><p>设置声道数。</p>
</dd></dl>

<dl class="method">
<dt id="wave.Wave_write.setsampwidth">
<code class="descclassname">Wave_write.</code><code class="descname">setsampwidth</code><span class="sig-paren">(</span><em>n</em><span class="sig-paren">)</span><a class="headerlink" href="#wave.Wave_write.setsampwidth" title="永久链接至目标">¶</a></dt>
<dd><p>设置采样字节长度为 <em>n</em>。</p>
</dd></dl>

<dl class="method">
<dt id="wave.Wave_write.setframerate">
<code class="descclassname">Wave_write.</code><code class="descname">setframerate</code><span class="sig-paren">(</span><em>n</em><span class="sig-paren">)</span><a class="headerlink" href="#wave.Wave_write.setframerate" title="永久链接至目标">¶</a></dt>
<dd><p>设置采样频率为 <em>n</em>。</p>
<div class="versionchanged">
<p><span class="versionmodified">在 3.2 版更改: </span>A non-integral input to this method is rounded to the nearest
integer.</p>
</div>
</dd></dl>

<dl class="method">
<dt id="wave.Wave_write.setnframes">
<code class="descclassname">Wave_write.</code><code class="descname">setnframes</code><span class="sig-paren">(</span><em>n</em><span class="sig-paren">)</span><a class="headerlink" href="#wave.Wave_write.setnframes" title="永久链接至目标">¶</a></dt>
<dd><p>Set the number of frames to <em>n</em>.  This will be changed later if the number
of frames actually written is different (this update attempt will
raise an error if the output stream is not seekable).</p>
</dd></dl>

<dl class="method">
<dt id="wave.Wave_write.setcomptype">
<code class="descclassname">Wave_write.</code><code class="descname">setcomptype</code><span class="sig-paren">(</span><em>type</em>, <em>name</em><span class="sig-paren">)</span><a class="headerlink" href="#wave.Wave_write.setcomptype" title="永久链接至目标">¶</a></dt>
<dd><p>设置压缩格式。目前只支持 <code class="docutils literal notranslate"><span class="pre">NONE</span></code> 即无压缩格式。</p>
</dd></dl>

<dl class="method">
<dt id="wave.Wave_write.setparams">
<code class="descclassname">Wave_write.</code><code class="descname">setparams</code><span class="sig-paren">(</span><em>tuple</em><span class="sig-paren">)</span><a class="headerlink" href="#wave.Wave_write.setparams" title="永久链接至目标">¶</a></dt>
<dd><p><em>tuple</em> 应该是 <code class="docutils literal notranslate"><span class="pre">(nchannels,</span> <span class="pre">sampwidth,</span> <span class="pre">framerate,</span> <span class="pre">nframes,</span> <span class="pre">comptype,</span> <span class="pre">compname)</span></code>，每项的值应可用于 <code class="xref py py-meth docutils literal notranslate"><span class="pre">set*()</span></code> 方法。设置所有形参。</p>
</dd></dl>

<dl class="method">
<dt id="wave.Wave_write.tell">
<code class="descclassname">Wave_write.</code><code class="descname">tell</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#wave.Wave_write.tell" title="永久链接至目标">¶</a></dt>
<dd><p>返回当前文件指针，其指针含义和 <a class="reference internal" href="#wave.Wave_read.tell" title="wave.Wave_read.tell"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Wave_read.tell()</span></code></a> 以及 <a class="reference internal" href="#wave.Wave_read.setpos" title="wave.Wave_read.setpos"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Wave_read.setpos()</span></code></a> 是一致的。</p>
</dd></dl>

<dl class="method">
<dt id="wave.Wave_write.writeframesraw">
<code class="descclassname">Wave_write.</code><code class="descname">writeframesraw</code><span class="sig-paren">(</span><em>data</em><span class="sig-paren">)</span><a class="headerlink" href="#wave.Wave_write.writeframesraw" title="永久链接至目标">¶</a></dt>
<dd><p>写入音频数据但不更新 <em>nframes</em>。</p>
<div class="versionchanged">
<p><span class="versionmodified">在 3.4 版更改: </span>Any <a class="reference internal" href="../glossary.html#term-bytes-like-object"><span class="xref std std-term">bytes-like object</span></a> is now accepted.</p>
</div>
</dd></dl>

<dl class="method">
<dt id="wave.Wave_write.writeframes">
<code class="descclassname">Wave_write.</code><code class="descname">writeframes</code><span class="sig-paren">(</span><em>data</em><span class="sig-paren">)</span><a class="headerlink" href="#wave.Wave_write.writeframes" title="永久链接至目标">¶</a></dt>
<dd><p>Write audio frames and make sure <em>nframes</em> is correct.  It will raise an
error if the output stream is not seekable and the total number of frames
that have been written after <em>data</em> has been written does not match the
previously set value for <em>nframes</em>.</p>
<div class="versionchanged">
<p><span class="versionmodified">在 3.4 版更改: </span>Any <a class="reference internal" href="../glossary.html#term-bytes-like-object"><span class="xref std std-term">bytes-like object</span></a> is now accepted.</p>
</div>
</dd></dl>

<p>注意在调用 <code class="xref py py-meth docutils literal notranslate"><span class="pre">writeframes()</span></code> 或 <code class="xref py py-meth docutils literal notranslate"><span class="pre">writeframesraw()</span></code> 之后再设置任何格式参数是无效的，而且任何这样的尝试将引发 <a class="reference internal" href="#wave.Error" title="wave.Error"><code class="xref py py-exc docutils literal notranslate"><span class="pre">wave.Error</span></code></a>。</p>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
  <h3><a href="../contents.html">Table of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#"><code class="docutils literal notranslate"><span class="pre">wave</span></code> --- 读写WAV格式文件</a><ul>
<li><a class="reference internal" href="#wave-read-objects">Wave_read对象</a></li>
<li><a class="reference internal" href="#wave-write-objects">Wave_write 对象</a></li>
</ul>
</li>
</ul>

  <h4>上一个主题</h4>
  <p class="topless"><a href="sunau.html"
                        title="上一章"><code class="docutils literal notranslate"><span class="pre">sunau</span></code> --- 读写 Sun AU 文件</a></p>
  <h4>下一个主题</h4>
  <p class="topless"><a href="chunk.html"
                        title="下一章"><code class="docutils literal notranslate"><span class="pre">chunk</span></code> --- Read IFF chunked data</a></p>
  <div role="note" aria-label="source link">
    <h3>本页</h3>
    <ul class="this-page-menu">
      <li><a href="../bugs.html">提交 Bug</a></li>
      <li>
        <a href="https://github.com/python/cpython/blob/3.7/Doc/library/wave.rst"
            rel="nofollow">显示源代码
        </a>
      </li>
    </ul>
  </div>
        </div>
      </div>
      <div class="clearer"></div>
    </div>  
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>导航</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="总目录"
             >索引</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python 模块索引"
             >模块</a> |</li>
        <li class="right" >
          <a href="chunk.html" title="chunk --- Read IFF chunked data"
             >下一页</a> |</li>
        <li class="right" >
          <a href="sunau.html" title="sunau --- 读写 Sun AU 文件"
             >上一页</a> |</li>
        <li><img src="../_static/py.png" alt=""
                 style="vertical-align: middle; margin-top: -1px"/></li>
        <li><a href="https://www.python.org/">Python</a> &#187;</li>
        <li>
          <span class="language_switcher_placeholder">zh_CN</span>
          <span class="version_switcher_placeholder">3.7.3</span>
          <a href="../index.html">文档</a> &#187;
        </li>

          <li class="nav-item nav-item-1"><a href="index.html" >Python 标准库</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="mm.html" >多媒体服务</a> &#187;</li>
    <li class="right">
        

    <div class="inline-search" style="display: none" role="search">
        <form class="inline-search" action="../search.html" method="get">
          <input placeholder="快速搜索" type="text" name="q" />
          <input type="submit" value="转向" />
          <input type="hidden" name="check_keywords" value="yes" />
          <input type="hidden" name="area" value="default" />
        </form>
    </div>
    <script type="text/javascript">$('.inline-search').show(0);</script>
         |
    </li>

      </ul>
    </div>  
    <div class="footer">
    &copy; <a href="../copyright.html">版权所有</a> 2001-2019, Python Software Foundation.
    <br />
    Python 软件基金会是一个非盈利组织。
    <a href="https://www.python.org/psf/donations/">请捐助。</a>
    <br />
    最后更新于 4月 09, 2019.
    <a href="../bugs.html">发现了问题</a>？
    <br />
    使用<a href="http://sphinx.pocoo.org/">Sphinx</a>1.8.4 创建。
    </div>

  </body>
</html>